#include "../inc/sched.h"
#include <linux/sched/clock.h>
#include <linux/sched/deadline.h>

void __set_task_cpu(struct task_struct *p, unsigned int cpu)
{
    //todo cgroup set_task_rq(p, cpu);
#ifdef CONFIG_SMP
    /*
     * After ->cpu is set up to a new value, task_rq_lock(p, ...) can be
     * successfully executed on another CPU. We must ensure that updates of
     * per-task data have been completed by this moment.
     */
    smp_wmb();
    WRITE_ONCE(task_thread_info(p)->cpu, cpu);
    p->wake_cpu = cpu;
#endif /* CONFIG_SMP */
}

#if defined(CONFIG_SMP)
unsigned int task_cpu(const struct task_struct *p)
{
    return task_thread_info(p)->cpu;
}

void set_task_cpu(struct task_struct *p, unsigned int cpu)
{
    __set_task_cpu(p, cpu);
}
#else
unsigned int task_cpu(const struct task_struct *p)
{
    return 0;
}

void set_task_cpu(struct task_struct *p, unsigned int cpu)
{
}
#endif
